/*
    SUSAN® - Sole of Unix Save ANything

   

   

   

   
*/
#if defined(HAVE_MINGW)
#include "include/susan.h"
#include "gtest/gtest.h"
#else
#include "gtest/gtest.h"
#include "include/susan.h"
#endif

#include "lib/edit.h"


TEST(acl_entry_syntax_test, acl_entry_syntax_test)
{
  std::vector<char> msg;

  EXPECT_EQ(true, IsAclEntryValid("list", msg));

  EXPECT_EQ(false, IsAclEntryValid("list,add", msg));
  EXPECT_STREQ("Illegal character \",\" in acl.\n", msg.data());

  EXPECT_EQ(true, IsAclEntryValid("STRING.CONTAINING.ALLOWED.CHARS!*.", msg));

  std::string string_maximum_length(MAX_NAME_LENGTH - 1, '.');
  EXPECT_EQ(true, IsAclEntryValid(string_maximum_length.c_str(), msg));

  EXPECT_EQ(false, IsAclEntryValid("illegalch@racter", msg));
  EXPECT_STREQ("Illegal character \"@\" in acl.\n", msg.data());

  EXPECT_EQ(false, IsAclEntryValid("", msg));
  EXPECT_STREQ("Acl must be at least one character long.\n", msg.data());

  EXPECT_EQ(false, IsAclEntryValid(nullptr, msg));
  EXPECT_STREQ("Empty acl not allowed.\n", msg.data());

  std::string string_too_long(MAX_NAME_LENGTH, '.');
  EXPECT_EQ(false, IsAclEntryValid(string_too_long.c_str(), msg));

  EXPECT_STREQ("Acl too long.\n", msg.data());
}
